|
|
|
|
|
|
|
Puzzle 7
Supercharged Graphics |
|
|
|
|
|
|
|
|
Among the most useful Win32 API functions is a set of graphic primitives that put those offered by Visual Basic to shame. Many of the Win32 graphic functions provide not only complex drawing and filling capabilities, but also blinding speed. This is, in part, why Windows is able to delegate many drawing operations to your graphic card or printer engine instead of rendering the image on your computer. |
|
|
|
|
|
|
|
|
In this example, we'll take a look at one of the more simple graphing functionsthe Polyline function. This function is defined as follows in the Win32 SDK: |
|
|
|
|
|
|
|
|
BOOL Polyline( HDC hdc, // handle of device context
CONST POINT *lppt, // address of array containing endpoints
int cPoints // number of points in the array
); |
|
|
|
|
|
|
|
|
The hdc parameter is the handle of a device context for drawing. Like most handles, this is a Long value. |
|
|
|
|
|
|
|
|
The lppt parameter is an array of POINT structures. The CONST keyword simply indicates that the values in this array are not modified by the API function. |
|
|
|
|
|
|
|
|
The nCount parameter is the number of entries in the arraythe number of points in the lines. The function will draw a line from each point to the next in the array using the current color. |
|
|
|
|
|
|
|
|
A POINT structure is defined in C as follows: |
|
|
|
|
|
|
|
|
typedef struct tagPOINT
{
LONG x;
LONG y;
} POINT; |
|
|
|
|
|